package com.pro.controller;

import com.pro.pojo.*;
import com.pro.service.CommentService;
import com.pro.utils.SensitiveWordsUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
* @Title: 评论的controller层
* @author 许振杰
* @date 2022/1/15 0015 10:08
* @version V1.0
*/
@Controller
@RequestMapping("/comment")
public class CommentController {

    @Autowired
    private CommentService commentService;

    //铭感词过滤
    SensitiveWordsUtil wordsUtil = new SensitiveWordsUtil();
    /**
    * @Title: 前端所有课程评论
    * @author 许振杰
    * @date 2022/1/15 0015 16:27
    * @version V1.0
    */
    @RequestMapping(value = "getBeforeProductComment")
    @ResponseBody
    public JsonData getBeforeProductComment(Integer type,Integer userType){
        List<JsComment> beforeProductComment = commentService.getBeforeProductComment(type, userType);
        beforeProductComment = wordsUtil.getListFilter(beforeProductComment);
        return beforeProductComment != null ? JsonData.buildSuccess(beforeProductComment) : JsonData.buildError("服务器出错了");
    }

    /**
    * @Title: 后台所有课程评论
    * @author 许振杰
    * @date 2022/1/15 0015 16:27
    * @version V1.0
    */
    @RequestMapping(value = "getUserProductComment")
    @ResponseBody
    public JsonData getUserProductComment(Integer type,Integer userType){
        List<JsComment> userProductComment = commentService.getUserProductComment(type, userType);
        userProductComment = wordsUtil.getListFilter(userProductComment);
        return userProductComment != null ? JsonData.buildSuccess(userProductComment) : JsonData.buildError("服务器出错了");
    }

    /**
    * @Title: 查询全部评论的数量
    * @author 许振杰
    * @date 2022/1/17 0017 13:58
    * @version V1.0
    */
    @RequestMapping(value = "getCommentCount")
    @ResponseBody
    public JsonData getCommentCount(Integer type,Integer userType){
        Integer commentCount = commentService.getCommentCount(type, userType);
        return commentCount != null ? JsonData.buildSuccess(commentCount) : JsonData.buildError("服务器出错了");
    }

    /**
    * @Title: 根据不同的状态查询评论数量
    * @author 许振杰
    * @date 2022/1/17 0017 14:00
    * @version V1.0
    */
    @RequestMapping(value = "getCommentCountByStatus")
    @ResponseBody
    public JsonData getCommentCountByStatus(Integer type,Integer userType,Integer status){
        Integer commentCountByStatus = commentService.getCommentCountByStatus(type, userType, status);
        return commentCountByStatus != null ? JsonData.buildSuccess(commentCountByStatus) : JsonData.buildError("服务器出错了");
    }

    /**
    * @Title: 查询不同的状态的前端课程评论
    * @author Administrator
    * @date 2022/1/17 0017 15:06
    * @version V1.0
    */
    @RequestMapping(value = "getBeforeProductCommentByStatus")
    @ResponseBody
    public JsonData getBeforeProductCommentByStatus(Integer type,Integer userType,Integer status){
        List<JsComment> beforeProductCommentByStatus = commentService.getBeforeProductCommentByStatus(type, userType, status);
        beforeProductCommentByStatus = wordsUtil.getListFilter(beforeProductCommentByStatus);
        return beforeProductCommentByStatus != null ? JsonData.buildSuccess(beforeProductCommentByStatus) : JsonData.buildError("服务器出错了");
    }

    /**
    * @Title: 查询不同的状态的后台课程评论
    * @author Administrator
    * @date 2022/1/17 0017 15:08
    * @version V1.0
    */
    @RequestMapping(value = "getUserProductCommentByStatus")
    @ResponseBody
    public JsonData getUserProductCommentByStatus(Integer type,Integer userType,Integer status){
        List<JsComment> userProductCommentByStatus = commentService.getUserProductCommentByStatus(type, userType, status);
        userProductCommentByStatus = wordsUtil.getListFilter(userProductCommentByStatus);
        return userProductCommentByStatus != null ? JsonData.buildSuccess(userProductCommentByStatus) : JsonData.buildError("服务器出错了");
    }

    /**
    * @Title: 修改评论状态
    * @author 许振杰
    * @date 2022/1/17 0017 16:17
    * @version V1.0
    */
    @RequestMapping(value = "editComment")
    @ResponseBody
    public JsonData editComment(Integer id,Integer status){
        boolean editComment = commentService.editComment(id, status);
        return editComment ? JsonData.buildSuccess(editComment) : JsonData.buildError("服务器出错了");
    }

    /**
    * @Title: 删除评论
    * @author 许振杰
    * @date 2022/1/17 0017 16:19
    * @version V1.0
    */
    @RequestMapping(value = "delComment")
    @ResponseBody
    public JsonData delComment(Integer id){
        boolean delComment = commentService.delComment(id);
        return delComment ? JsonData.buildSuccess(delComment) : JsonData.buildError("服务器出错了");
    }

    /**
    * @Title: 查询历史评论人数
    * @author 许振杰
    * @date 2022/1/17 0017 19:45
    * @version V1.0
    */
    @RequestMapping(value = "historyCommentPeople")
    @ResponseBody
    public JsonData historyCommentPeople(Integer type,Integer userType){
        Integer historyCommentPeople = commentService.historyCommentPeople(type, userType);
        return historyCommentPeople != null ? JsonData.buildSuccess(historyCommentPeople) : JsonData.buildError("服务器出错了");
    }

    /**
    * @Title: 查询评论的用户和时间
    * @author 许振杰
    * @date 2022/1/17 0017 19:47
    * @version V1.0
    */
    @RequestMapping(value = "getCommentUserAndData")
    @ResponseBody
    public JsonData getCommentUserAndData(Integer type,Integer userType){
        List<JsComment> commentUserAndData = commentService.getCommentUserAndData(type, userType);
        return commentUserAndData != null ? JsonData.buildSuccess(commentUserAndData) : JsonData.buildError("服务器出错了");
    }

    /**
    * @Title: 微圈前台全部评论
    * @author 许振杰
    * @date 2022/1/19 0019 15:42
    * @version V1.0
    */
    @RequestMapping(value = "getBeforeMicrocircleComment")
    @ResponseBody
    public JsonData getBeforeMicrocircleComment(Integer type,Integer userType){
        List<JsComment> beforeMicrocircleComment = commentService.getBeforeMicrocircleComment(type, userType);
        beforeMicrocircleComment = wordsUtil.getListFilter(beforeMicrocircleComment);
        return beforeMicrocircleComment != null ? JsonData.buildSuccess(beforeMicrocircleComment) : JsonData.buildError("服务器出错了");
    }

    /**
    * @Title: 微圈后台全部评论
    * @author 许振杰
    * @date 2022/1/19 0019 15:44
    * @version V1.0
    */
    @RequestMapping(value = "getUserMicrocircleComment")
    @ResponseBody
    public JsonData getUserMicrocircleComment(Integer type,Integer userType){
        List<JsComment> userMicrocircleComment = commentService.getUserMicrocircleComment(type, userType);
        userMicrocircleComment = wordsUtil.getListFilter(userMicrocircleComment);
        return userMicrocircleComment != null ? JsonData.buildSuccess(userMicrocircleComment) : JsonData.buildError("服务器出错了");
    }

    /**
    * @Title: 根据不同的状态查询前端微圈评论
    * @author 许振杰
    * @date 2022/1/19 0019 16:32
    * @version V1.0
    */
    @RequestMapping(value = "getBeforeMicrocircleCommentByStatus")
    @ResponseBody
    public JsonData getBeforeMicrocircleCommentByStatus(Integer type,Integer userType,Integer status){
        List<JsComment> beforeMicrocircleCommentByStatus = commentService.getBeforeMicrocircleCommentByStatus(type, userType, status);
        beforeMicrocircleCommentByStatus = wordsUtil.getListFilter(beforeMicrocircleCommentByStatus);
        return beforeMicrocircleCommentByStatus != null ? JsonData.buildSuccess(beforeMicrocircleCommentByStatus) : JsonData.buildError("服务器出错了");
    }

    /**
    * @Title: 根据不同的状态查询后端微圈评论
    * @author 许振杰
    * @date 2022/1/19 0019 16:32
    * @version V1.0
    */
    @RequestMapping(value = "getUserMicrocircleCommentByStatus")
    @ResponseBody
    public JsonData getUserMicrocircleCommentByStatus(Integer type,Integer userType,Integer status){
        List<JsComment> userMicrocircleCommentByStatus = commentService.getUserMicrocircleCommentByStatus(type, userType, status);
        userMicrocircleCommentByStatus = wordsUtil.getListFilter(userMicrocircleCommentByStatus);
        return userMicrocircleCommentByStatus != null ? JsonData.buildSuccess(userMicrocircleCommentByStatus) : JsonData.buildError("服务器出错了");

    }

    /**
    * @Title: 判断当前登录用户是前台用户还是后台用户
    * @author 许振杰
    * @date 2022/1/19 0019 20:16
    * @version V1.0
    */
    @RequestMapping(value = "getDeptId")
    @ResponseBody
    public JsonData getDeptId(Integer userId,String account){
        List<JsUser> deptId = commentService.getDeptId(userId, account);
        return deptId != null ? JsonData.buildSuccess(deptId) : JsonData.buildError("服务器出错了");
    }

    /**
    * @Title: 查询前端课程评论
    * @author 许振杰
    * @date 2022/1/20 0020 14:44
    * @version V1.0
    */
    @RequestMapping(value = "getBeforCourseComment")
    @ResponseBody
    public JsonData getBeforCourseComment(Integer type,Integer userType){
        List<JsComment> beforCourseComment = commentService.getBeforCourseComment(type, userType);
        beforCourseComment = wordsUtil.getListFilter(beforCourseComment);
        return beforCourseComment != null ? JsonData.buildSuccess(beforCourseComment) : JsonData.buildError("服务器出错了");
    }

    /**
    * @Title: 查询后端课程评论
    * @author 许振杰
    * @date 2022/1/20 0020 14:46
    * @version V1.0
    */
    @RequestMapping(value = "getUserCourseComment")
    @ResponseBody
    public JsonData getUserCourseComment(Integer type,Integer userType){
        List<JsComment> userCourseComment = commentService.getUserCourseComment(type, userType);
        userCourseComment = wordsUtil.getListFilter(userCourseComment);
        return userCourseComment != null ? JsonData.buildSuccess(userCourseComment) : JsonData.buildError("服务器出错了");
    }

    /**
    * @Title: 根据不同的状态查询前端课程评论
    * @author 许振杰
    * @date 2022/1/20 0020 14:47
    * @version V1.0
    */
    @RequestMapping(value = "getBeforCourseCommentByStatus")
    @ResponseBody
    public JsonData getBeforCourseCommentByStatus(Integer type,Integer userType,Integer status){
        List<JsComment> beforCourseCommentByStatus = commentService.getBeforCourseCommentByStatus(type, userType, status);
        beforCourseCommentByStatus = wordsUtil.getListFilter(beforCourseCommentByStatus);
        return beforCourseCommentByStatus != null ? JsonData.buildSuccess(beforCourseCommentByStatus) : JsonData.buildError("服务器出错了");
    }

    /**
    * @Title: 根据不同的状态查询后端课程评论
    * @author 许振杰
    * @date 2022/1/20 0020 14:49
    * @version V1.0
    */
    @RequestMapping(value = "getUserCourseCommentByStatus")
    @ResponseBody
    public JsonData getUserCourseCommentByStatus(Integer type,Integer userType,Integer status){
        List<JsComment> userCourseCommentByStatus = commentService.getUserCourseCommentByStatus(type, userType, status);
        userCourseCommentByStatus = wordsUtil.getListFilter(userCourseCommentByStatus);
        return userCourseCommentByStatus != null ? JsonData.buildSuccess(userCourseCommentByStatus) : JsonData.buildError("服务器出错了");
    }

    /**
    * @Title: 根据评论id查询微圈信息
    * @author 许振杰
    * @date 2022/1/21 0021 15:19
    * @version V1.0
    */
    @RequestMapping(value = "getMicrocircleInformationById")
    @ResponseBody
    public JsonData getMicrocircleInformationById(Integer id){
        JsMicrocircle microcircleInformationById = commentService.getMicrocircleInformationById(id);
        return microcircleInformationById != null ? JsonData.buildSuccess(microcircleInformationById) : JsonData.buildError("服务器出错了");
    }

    /**
    * @Title: 根据评论id查询课程信息
    * @author 许振杰
    * @date 2022/1/21 0021 15:21
    * @version V1.0
    */
    @RequestMapping(value = "getCourseInformationById")
    @ResponseBody
    public JsonData getCourseInformationById(Integer id){
        JsCourse courseInformationById = commentService.getCourseInformationById(id);
        return courseInformationById != null ? JsonData.buildSuccess(courseInformationById) : JsonData.buildError("服务器出错了");
    }

    /**
    * @Title: 根据评论id查询商品信息
    * @author 许振杰
    * @date 2022/1/21 0021 15:23
    * @version V1.0
    */
    @RequestMapping(value = "getProductInformationById")
    @ResponseBody
    public JsonData getProductInformationById(Integer id){
        JsProduct productInformationById = commentService.getProductInformationById(id);
        return productInformationById != null ? JsonData.buildSuccess(productInformationById) : JsonData.buildError("服务器出错了");
    }

    /**
    * @Title: 个人前端课程评论
    * @author 许振杰
    * @date 2022/1/21 0021 21:12
    * @version V1.0
    */
    @RequestMapping(value = "getPersonalCourseBeforeComment")
    @ResponseBody
    public JsonData getPersonalCourseBeforeComment(Integer type,Integer userType,Integer userId){
        List<JsComment> personalCourseBeforeComment = commentService.getPersonalCourseBeforeComment(type, userType, userId);
        personalCourseBeforeComment = wordsUtil.getListFilter(personalCourseBeforeComment);
        return personalCourseBeforeComment != null ? JsonData.buildSuccess(personalCourseBeforeComment) : JsonData.buildError("服务器出错了");
    }

    /**
    * @Title: 个人后台课程评论
    * @author 许振杰
    * @date 2022/1/21 0021 21:21
    * @version V1.0
    */
    @RequestMapping(value = "getPersonalCourseUserComment")
    @ResponseBody
    public JsonData  getPersonalCourseUserComment(Integer type,Integer userType,Integer userId){
        List<JsComment> personalCourseUserComment = commentService.getPersonalCourseUserComment(type, userType, userId);
        personalCourseUserComment = wordsUtil.getListFilter(personalCourseUserComment);
        return personalCourseUserComment != null ? JsonData.buildSuccess(personalCourseUserComment) : JsonData.buildError("服务器出错了");
    }

    /**
    * @Title: 查询个人不同状态下的前端课程评论
    * @author 许振杰
    * @date 2022/1/21 0021 21:29
    * @version V1.0
    */
    @RequestMapping(value = "getPersonalCourseBeforeCommentByStatus")
    @ResponseBody
    public JsonData getPersonalCourseBeforeCommentByStatus(Integer type,Integer userType,Integer userId,Integer status){
        List<JsComment> personalCourseBeforeCommentByStatus = commentService.getPersonalCourseBeforeCommentByStatus(type, userType, userId, status);
        personalCourseBeforeCommentByStatus = wordsUtil.getListFilter(personalCourseBeforeCommentByStatus);
        return personalCourseBeforeCommentByStatus != null ? JsonData.buildSuccess(personalCourseBeforeCommentByStatus) : JsonData.buildError("服务器出错了");
    }

    /**
    * @Title: 查询个人不同状态下的后端课程评论
    * @author 许振杰
    * @date 2022/1/21 0021 21:32
    * @version V1.0
    */
    @RequestMapping(value = "getPersonalCourseUserCommentByStatus")
    @ResponseBody
    public JsonData getPersonalCourseUserCommentByStatus(Integer type,Integer userType,Integer userId,Integer status){
        List<JsComment> personalCourseUserCommentByStatus = commentService.getPersonalCourseUserCommentByStatus(type, userType, userId, status);
        personalCourseUserCommentByStatus = wordsUtil.getListFilter(personalCourseUserCommentByStatus);
        return personalCourseUserCommentByStatus != null ? JsonData.buildSuccess(personalCourseUserCommentByStatus) : JsonData.buildError("服务器出错了");
    }

    /**
    * @Title: 查询个人不同商品的全部评论数量
    * @author 许振杰
    * @date 2022/1/22 0022 16:10
    * @version V1.0
    */
    @RequestMapping(value = "getPersonalCommentCount")
    @ResponseBody
    public JsonData getPersonalCommentCount(Integer type,Integer userType,Integer userId){
        Integer personalCommentCount = commentService.getPersonalCommentCount(type, userType, userId);
        return personalCommentCount != null ? JsonData.buildSuccess(personalCommentCount) : JsonData.buildError("服务器出错了");
    }

    /**
    * @Title: 查询个人不同状态下的评论数量
    * @author 许振杰
    * @date 2022/1/22 0022 16:11
    * @version V1.0
    */
    @RequestMapping(value = "getPersonalCommentCountByStatus")
    @ResponseBody
    public JsonData getPersonalCommentCountByStatus(JsComment comment){
        Integer personalCommentCountByStatus = commentService.getPersonalCommentCountByStatus(comment);
        return personalCommentCountByStatus != null ? JsonData.buildSuccess(personalCommentCountByStatus) : JsonData.buildError("服务器出错了");
    }

    /**
    * @Title: 个人历史评论人数
    * @author 许振杰
    * @date 2022/1/22 0022 16:47
    * @version V1.0
    */
    @RequestMapping(value = "personalHistoryComment")
    @ResponseBody
    public JsonData personalHistoryComment(Integer userType,Integer type,Integer userId){
        Integer personalHistoryComment  = commentService.personalHistoryComment(userType, type, userId);
        return personalHistoryComment != null ? JsonData.buildSuccess(personalHistoryComment) : JsonData.buildError("服务器出错了");
    }


    /**
    * @Title: 个人前端微圈评论
    * @author 许振杰
    * @date 2022/1/22 0022 21:43
    * @version V1.0
    */
    @RequestMapping(value = "getPersonalBeforeMicrocircleComment")
    @ResponseBody
    public JsonData getPersonalBeforeMicrocircleComment(Integer type, Integer userType, Integer userId){
        List<JsComment> personalBeforeMicrocircleComment = commentService.getPersonalBeforeMicrocircleComment(type, userType, userId);
        personalBeforeMicrocircleComment = wordsUtil.getListFilter(personalBeforeMicrocircleComment);
        return personalBeforeMicrocircleComment != null ? JsonData.buildSuccess(personalBeforeMicrocircleComment) : JsonData.buildError("服务器出错了");
    }

    /**
    * @Title: 个人后端微圈评论
    * @author 许振杰
    * @date 2022/1/22 0022 21:45
    * @version V1.0
    */
    @RequestMapping(value = "getPersonalUserMicrocircleComment")
    @ResponseBody
    public JsonData getPersonalUserMicrocircleComment(Integer type, Integer userType, Integer userId){
        List<JsComment> personalUserMicrocircleComment = commentService.getPersonalUserMicrocircleComment(type, userType, userId);
        personalUserMicrocircleComment = wordsUtil.getListFilter(personalUserMicrocircleComment);
        return personalUserMicrocircleComment != null ? JsonData.buildSuccess(personalUserMicrocircleComment) : JsonData.buildError("服务器出错了");
    }

    /**
    * @Title: 根据不停状态查询个人前端微圈评论
    * @author 许振杰
    * @date 2022/1/22 0022 21:46
    * @version V1.0
    */
    @RequestMapping(value = "getPersonalBeforeMicrocircleCommentByStatus")
    @ResponseBody
    public JsonData getPersonalBeforeMicrocircleCommentByStatus(Integer type, Integer userType, Integer userId, Integer status){
        List<JsComment> personalBeforeMicrocircleCommentByStatus = commentService.getPersonalBeforeMicrocircleCommentByStatus(type, userType, userId, status);
        personalBeforeMicrocircleCommentByStatus = wordsUtil.getListFilter(personalBeforeMicrocircleCommentByStatus);
        return personalBeforeMicrocircleCommentByStatus != null ? JsonData.buildSuccess(personalBeforeMicrocircleCommentByStatus) : JsonData.buildError("服务器出错了");
    }

    /**
    * @Title: 根据不停状态查询个人后端微圈评论
    * @author 许振杰
    * @date 2022/1/22 0022 21:47
    * @version V1.0
    */
    @RequestMapping(value = "getPersonalUserMicrocircleCommentByStatus")
    @ResponseBody
    public JsonData getPersonalUserMicrocircleCommentByStatus(Integer type, Integer userType, Integer userId, Integer status){
        List<JsComment> personalUserMicrocircleCommentByStatus = commentService.getPersonalUserMicrocircleCommentByStatus(type, userType, userId, status);
        personalUserMicrocircleCommentByStatus = wordsUtil.getListFilter(personalUserMicrocircleCommentByStatus);
        return personalUserMicrocircleCommentByStatus != null ? JsonData.buildSuccess(personalUserMicrocircleCommentByStatus) : JsonData.buildError("服务器出错了");
    }

    /**
    * @Title: 个人前端商品评论
    * @author 许振杰
    * @date 2022/1/22 0022 22:26
    * @version V1.0
    */
    @RequestMapping(value = "getPersonalBeforeProductComment")
    @ResponseBody
    public JsonData getPersonalBeforeProductComment(Integer type,Integer userType,Integer userId){
        List<JsComment> personalBeforeProductComment = commentService.getPersonalBeforeProductComment(type, userType, userId);
        personalBeforeProductComment = wordsUtil.getListFilter(personalBeforeProductComment);
        return personalBeforeProductComment != null ? JsonData.buildSuccess(personalBeforeProductComment) : JsonData.buildError("服务器出错了");
    }

    /**
    * @Title: 个人后台商品评论
    * @author 许振杰
    * @date 2022/1/22 0022 22:27
    * @version V1.0
    */
    @RequestMapping(value = "getPersonalUserProductComment")
    @ResponseBody
    public JsonData getPersonalUserProductComment(Integer type,Integer userType,Integer userId){
        List<JsComment> personalUserProductComment = commentService.getPersonalUserProductComment(type, userType, userId);
        personalUserProductComment = wordsUtil.getListFilter(personalUserProductComment);
        return personalUserProductComment != null ? JsonData.buildSuccess(personalUserProductComment) : JsonData.buildError("服务器出错了");
    }

    /**
    * @Title: 根据不同的状态查询个人前端商品评论
    * @author 许振杰
    * @date 2022/1/22 0022 22:28
    * @version V1.0
    */
    @RequestMapping(value = "getPersonalBeforeProductCommentByStatus")
    @ResponseBody
    public JsonData getPersonalBeforeProductCommentByStatus(Integer type,Integer userType,Integer userId,Integer status){
        List<JsComment> personalBeforeProductCommentByStatus = commentService.getPersonalBeforeProductCommentByStatus(type, userType, userId, status);
        personalBeforeProductCommentByStatus = wordsUtil.getListFilter(personalBeforeProductCommentByStatus);
        return personalBeforeProductCommentByStatus != null ? JsonData.buildSuccess(personalBeforeProductCommentByStatus) : JsonData.buildError("服务器出错了");
    }

    /**
    * @Title: 根据不同的状态查询个人后端商品评论
    * @author 许振杰
    * @date 2022/1/22 0022 22:29
    * @version V1.0
    */
    @RequestMapping(value = "getPersonalUserProductCommentByStatus")
    @ResponseBody
    public JsonData getPersonalUserProductCommentByStatus(Integer type,Integer userType,Integer userId,Integer status) {
        List<JsComment> personalUserProductCommentByStatus = commentService.getPersonalUserProductCommentByStatus(type, userType, userId, status);
        personalUserProductCommentByStatus = wordsUtil.getListFilter(personalUserProductCommentByStatus);
        return personalUserProductCommentByStatus != null ? JsonData.buildSuccess(personalUserProductCommentByStatus) : JsonData.buildError("服务器出错了");
    }


}
